[mirrors]
http://ftp.debian.org/debian/pool/main/c/ca-certificates/ca-certificates_20151214.tar.xz

[vars]
filesize=293672
sha512=acee5565aa7d1f0cc120a6abb6503e0ac4b4e12f5fd1cb12442ec1374ae1570ec6dc3a8f3a247fad6835a29d96e856f12c664f466e92344db3aa1ae6292a27ac
tardir=ca-certificates

[deps]
openssl

[deps.host]
openssl

[build]
$HOSTCC "$K"/c_rehash.c -o c_rehash -lssl -lcrypto
export PATH=$PWD:"$PATH"
mkdir -p "$butch_install_dir""$butch_prefix"/share/ca-certificates/mozilla
cat << EOF > sbin/Makefile
install:
	install -Dm755 update-ca-certificates \$(DESTDIR)\$(sbindir)/update-ca-certificates
EOF
cp "$K"/certdata2pem.c mozilla/
cat << EOF > mozilla/Makefile
all: a.out
	./a.out
a.out:
	\$(HOSTCC) -Wall -Wextra -O0 -g certdata2pem.c
clean:
	-rm -f *.crt
install:
	for p in *.crt; do \
	 install -D -m 644 \$\$p \$(CERTSDIR)/\$\$p ; \
	done
EOF
sed -i 's@/usr@'"$butch_prefix"'@g' sbin/update-ca-certificates
make CERTSDIR="$butch_prefix"/share/ca-certificates
make CERTSDIR="$butch_prefix"/share/ca-certificates \
     DESTDIR="$butch_install_dir" sbindir="$butch_prefix"/bin install

mkdir -p "$butch_install_dir/etc/ssl/certs"

( cd "$butch_install_dir/share/ca-certificates/"
  find . -name '*.crt' | sort | cut -b3- > "$butch_install_dir/etc/ca-certificates.conf" )

cp sbin/update-ca-certificates .
sed -e 's#=/etc/#=${DESTDIR}/etc/#' -i update-ca-certificates
sed -e 's#=/share/#=${DESTDIR}/share/#' -i update-ca-certificates
sed -e 's#=/local/#=${DESTDIR}/local/#' -i update-ca-certificates

DESTDIR="$butch_install_dir" sh ./update-ca-certificates --fresh

